#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
const int inf=0x7fffffff;


struct coin{
	int num,value,weight=1;
};


int main(){
	int n,t,ans=inf;
	scanf("%d%d",&n,&t);
	coin a[n];
	for(int i=0;i<n;i++)
		scanf("%d",&a[i].value);
	int sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i].num);
		sum += a[i].num*a[i].value;
	}
	
	int dp_b[sum-t+1],dp1_j[sum+1],dp2_j[sum+1];
	
	
	for(int i=0;i<=sum-t;i++)
		dp_b[i] = inf;
	dp_b[0] = 0;
	
	
	for(int i=0;i<=sum;i++){
		dp1_j[i] = inf;
		dp2_j[i] = inf;
	}
	dp1_j[0] = 0;
	dp2_j[0] = 0;
	
	
	//b
	for(int i=1;i<=n;i++)
		for(int j=a[i-1].value;j<=sum-t;j++)
			dp_b[j] = min(dp_b[j],dp_b[j-a[i-1].value]==inf?inf:dp_b[j-a[i-1].value]+a[i-1].weight);
	
	
	//j
	for(int i=1;i<=n;i++){
		for(int j=1;j<=sum;j++)
			for(int k=0;k<=min(a[i-1].num,j/a[i-1].value);k++)
				dp2_j[j] = min(dp2_j[j],dp1_j[j-k*a[i-1].value]==inf?inf:dp1_j[j-k*a[i-1].value]+k*a[i-1].weight);
		memcpy(dp1_j,dp2_j,sizeof(dp1_j));
	}
	
//	for(int i=0;i<=sum;i++)
//		cout<<(dp1_j[i]==inf?-1:dp1_j[i])<<" ";
//	cout<<endl;
//	
//	for(int i=0;i<=sum-t;i++)
//		cout<<(dp_b[i]==inf?-1:dp_b[i])<<" ";
//	cout<<endl;
//	
//	cout<<dp1_j[75]<<" "<<dp_b[5]<<endl;
	
	//cmp
	for(int i=0;i<=sum-t;i++)
		ans = min(ans,dp_b[i]+dp1_j[i+t]>=0?dp_b[i]+dp1_j[i+t]:inf);
	printf("%d",(ans==inf?-1:ans));
	return 0;
}
